package com.sky.controller.admin;

import com.sky.entity.EQ;
import com.sky.po.CompleteEx;
import com.sky.po.ReadyEx;
import com.sky.result.Result;
import com.sky.service.EqopService;
import com.sky.vo.DishVO;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/eqop")
public class EqopController {

    @Autowired
    private EqopService eqopService;

    @PostMapping("/delete/{id}")
    public Result deleteItem(@PathVariable Integer id) {
        eqopService.deleteOneById(id);
        return Result.success();
    }

    @PostMapping("/update/{id}")
    public Result<EQ> getById(@PathVariable Integer id) {
        System.out.println(id);
        EQ completeEx = eqopService.seleteById(id);
//        ReadyEx readyEx = new ReadyEx();
//        BeanUtils.copyProperties(completeEx, readyEx);
//        readyEx.setId(id);
        completeEx.setId(id);
        return Result.success(completeEx);
    }

    @PostMapping("/update")
    public Result<ReadyEx> update(@RequestBody ReadyEx readyEx) {
        eqopService.update(readyEx);
        return Result.success();
    }
}